<?php
session_start();
define('IN_WADMIN', true);
require_once '../include/common.php';
$title="后台管理";
include ('../include/head.php');
require_once './aconn.php';

$li=(isset( $_SESSION['w_adminname']))?'<li role="presentation"><a href="index.php">管理中心</a></li>':'<li role="presentation"><a href="index.php">后台登陆</a></li>';
echo '<div class="header">
        <ul class="nav nav-pills pull-right" role="tablist">
          <li role="presentation" class="active"><a href="../index.php">首页</a></li>
          '.$li.'
          <li role="presentation"><a href="index.php?action=logout">退出</a></li>
        </ul>
        <h3 class="text-muted" align="left">后台<body  background="http://zz.qqh.pw/1234.jpg"></body>管理</h3>
      </div><hr>';
	  
	  
if($_GET['action'] == "logout"){
    unset($_SESSION['w_adminname']);
	unset($_SESSION['w_adminid']);
	echo '退出成功!<br />3秒后自动跳转...<br />若无法跳转请<a href="index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php">';

include ('../include/foot.php');
exit;
}

	  
if(isset($_SESSION['w_adminname'])&&isset($_SESSION['w_adminid'])){
	$w_adminid=userid($_SESSION['w_adminname'],$key,$w_adminpwd);
	if($_SESSION['w_adminid']==$w_adminid){
		echo '<a href="#" class="list-group-item active">基本操作</a>
			<a href="do.php?do=pz" class="list-group-item">系统配置</a>
			<a href="do.php?do=pw" class="list-group-item">后台密码</a>
			<a href="do.php?do=list" class="list-group-item">挂机报表</a>
			<a href="do.php?do=index" class="list-group-item">首页介绍</a>
			<a href="http://xsmzan.aliapp.com/admin/update.php" class="list-group-item">检测更新</a>
			<a href="#" class="list-group-item active">用户操作</a>
			<a href="user.php?do=list" class="list-group-item">用户列表</a>
			<a href="user.php?do=czlist" class="list-group-item">充值记录</a>
			<a href="user.php?do=cont" class="list-group-item">文本内容</a>
			<a href="user.php?do=cimg" class="list-group-item">图片内容</a>
			<a href="#" class="list-group-item active">激活管理</a>
			<a href="user.php?do=jh" class="list-group-item">激活码管理</a>';
	}else{
		unset($_SESSION['w_adminname']);
		unset($_SESSION['w_adminid']);
		echo '非法访问!<br />3秒后自动跳转...<br />若无法跳转请<a href="index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php">';
	}
	
}else{
if (isset($_POST['adminname'])&&isset($_POST['adminpwd'])){
	if(!isset($_POST['submit'])){
		echo '非法访问!<br />3秒后自动跳转...<br />若无法跳转请<a href="../index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=../index.php">';
		include ('../include/foot.php');
		exit;
	}
	if(($_POST['adminname']==$w_adminname)&&(md5($_POST['adminpwd'])==$w_adminpwd)){
		$w_adminid=userid($w_adminname,$key,$w_adminpwd);
		if(!isset($_SESSION['w_adminname'])){ 
			$_SESSION['w_adminname']=$w_adminname;  
			$_SESSION['w_adminid']=$w_adminid; 
			echo '登陆成功!<br />3秒后自动跳转...<br />若无法跳转请<a href="index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php">';	
		}
	}else{
		
		echo '非法访问!<br />3秒后自动跳转...<br />若无法跳转请<a href="../index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=../index.php">';
	}
	
}else{
	echo '<h3 class="form-signin-heading">后台帐号</h3>
	 <form action="index.php" class="form-sign" method="post">
	 用户名<br>
	 <input type="text" class="form-control" name="adminname" value=""><br>
	 密码<br>
	 <input type="password" class="form-control" name="adminpwd" value=""><br>
	 <input type="submit" class="btn btn-primary btn-block" name="submit" value="点击登录"><br>';
}

}

include ('../include/foot.php');